home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / obsolete / polycontour.pro < prev    next >
Text File  |  1997-07-08  |  5KB  |  170 lines

  1. ; $Id: polycontour.pro,v 1.3 1997/01/15 04:02:19 ali Exp $
  2. ;
  3. ; Copyright (c) 1989-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5.  
  6. pro polycontour, filename, color_index=color_index, pattern = pat, $
  7.     DELETE_FILE=delfile
  8. ;+
  9. ; NAME:
  10. ;    POLYCONTOUR
  11. ;
  12. ; PURPOSE:
  13. ;    Fill the contours defined by a path file created by CONTOUR.
  14. ;    This routine has been obsoleted by the FILL option to CONTOUR,
  15. ;    and should NOT be used.
  16. ;
  17. ; CATEGORY:
  18. ;    Graphics.
  19. ;
  20. ; CALLING SEQUENCE:
  21. ;    POLYCONTOUR, Filename [, COLOR_INDEX = color_index]
  22. ;
  23. ; INPUTS:
  24. ;    Filename:    The name of a file containing contour paths.  This
  25. ;        file must have been created by using the CONTOUR
  26. ;        procedure:  CONTOUR, PATH=Filename, ...
  27. ;
  28. ; KEYWORD PARAMETERS:
  29. ; COLOR_INDEX:    An array of color indices for the filled contours.  Element 
  30. ;        i contains the color of contour level number i-1.  Element 
  31. ;        0 contains the background color.  There must be one more 
  32. ;        color index than the number of levels.
  33. ;
  34. ; DELETE_FILE:    If present and non-zero, Filename will be deleted after
  35. ;        POLYCONTOUR is finished with it.
  36. ;
  37. ;     PATTERN:    An optional array of patterns with the dimensions
  38. ;        (NX, NY, NPATTERN).
  39. ;
  40. ; OUTPUTS:
  41. ;    The contours are filled on the display using normalized
  42. ;    coordinates and the POLYFILL procedure.
  43. ;
  44. ; COMMON BLOCKS:
  45. ;    None.
  46. ;
  47. ; SIDE EFFECTS:
  48. ;    A filled contour plot is drawn to the current display.
  49. ;
  50. ; RESTRICTIONS:
  51. ;    This routine will NOT draw open contours.  To eliminate open
  52. ;    contours in your dataset, surround the original array with a 1-element
  53. ;    border on all sides.  The border should be set to a value less than
  54. ;    or equal to the minimum data array value.  
  55. ;
  56. ;    For example, if A is an (N,M) array enter:
  57. ;
  58. ;        B = REPLICATE(MIN(A), N+2, M+2)    ;Make background
  59. ;        B(1,1) = A            ;Insert original data
  60. ;        CONTOUR, B, PATH=Filename ...    ;Create the contour file.
  61. ;
  62. ; PROCEDURE:
  63. ;    The contour file is scaned to find the starting byte of each contour's
  64. ;    path.  Then POLYCONTOUR sorts the contour levels and reads each 
  65. ;    record, filling its path.  High contours are draw in increasing 
  66. ;    order, then Low contours are drawn in decreasing order.
  67. ;
  68. ; EXAMPLE:
  69. ;    Create a 8 by 8 array of random numbers, place it into a 10 by 10
  70. ;    array to eliminate open contours, polycontour it, then overdraw 
  71. ;    the contour lines.  Enter:
  72. ;
  73. ;        B = FLTARR(10,10)        ;Create a big array of 0's.
  74. ;        B(1,1) = RANDOMU(seed, 8,8)    ;Insert random numbers.
  75. ;        CONTOUR, b, /SPLINE, PATH = 'path.dat' ;Make the path file.
  76. ;        POLYCONTOUR, 'path.dat'        ;Fill the contours.
  77. ;        CONTOUR, b, /SPLINE, /NOERASE    ;Overplot lines & labels.
  78. ;
  79. ;    Suggestion:  Use TEK_COLOR to load a color table suitable
  80. ;             for viewing this display.
  81. ;
  82. ; MODIFICATION HISTORY:
  83. ;    DMS, AB, January, 1989.
  84. ;    DMS,     April, 1993.  Made it obsolete.
  85. ;-
  86.  
  87. COMMON POLYCONTOUR_MSG, count
  88.  
  89.  
  90. if n_elements(count) eq 0 then begin
  91.     count = 1
  92.     message, 'is obsolete, use CONTOUR, /FILL', /INFO
  93.     endif
  94.  
  95. on_error,2                      ;Return to caller if an error occurs
  96. header = {contour_header,$
  97.     type : 0B, $
  98.     high_low : 0B, $
  99.     level : 0, $
  100.     num : 0L, $
  101.     value : 0.0 }
  102.  
  103. max = 0
  104. if n_elements(color_index) eq 0 then color_index = indgen(25)+1
  105. asize = 100        ;# of elements in our arrays
  106. n = 0
  107. cval = intarr(asize)    ;Contour index
  108. cstart = lonarr(asize)    ;Starting byte of record
  109. openr, unit, filename, /GET_LUN, DELETE=keyword_set(delfile)
  110. while (not eof(unit)) do begin    ;First pass
  111.     a = fstat(unit)        ;File position
  112.     readu,unit,header    ;Read header
  113.     if (header.type eq 0) then $
  114.         message, 'Warning: Unclosed contour ignored.', /CONT $
  115.     else begin
  116.  
  117.     if n eq asize then begin    ;Expand our arrays?
  118.         cval = [cval,cval]    ;Yes, double them
  119.         cstart = [cstart,cstart]
  120.         asize = 2 * asize
  121.         endif
  122.         ;Color to draw
  123.     c = fix(header.level)
  124.     max = max > c
  125.     if header.high_low eq 0 then  c = 200 - c ;low contour
  126.     cval(n) = c            ;Contour index
  127.     cstart(n) = a.cur_ptr        ;Position    
  128.     n = n + 1
  129.     endelse
  130.      xyarr = fltarr(header.num,2)    ;Define point to skip
  131.      readu,unit,xyarr
  132.     endwhile
  133.  
  134. cval = cval(0:n-1)            ;Truncate
  135. cstart = cstart(0:n-1)
  136. order = sort(cval)            ;Subscripts of order
  137. for i=0,n-1 do begin            ;Draw each contour
  138.      j = order(i)            ;Index of record
  139.     point_lun,unit,cstart(j)
  140.     readu,unit,header        ;Reread header
  141.     if header.num le 2 then goto, skip ;A polygon?
  142.     xyarr = fltarr(header.num, 2)    ;Define points
  143.     readu,unit,xyarr        ;Read points
  144.     col = cval(j)            ;Drawing color
  145.     if col ge 100 then col = 199-col ;Drawing index = 1 less than orig
  146.     col = color_index(col+1)
  147.  
  148.     if n_elements(pat) ne 0 then begin
  149.         s = size(pat)
  150.         if s(0) ne 3 then message, 'Pattern array not 3d.'
  151.         polyfill,/NORMAL, pattern=pat(*,*, i mod s(3)), $
  152.             transpose(xyarr)
  153.     endif else $
  154.       polyfill, /NORMAL, color= col,transpose(xyarr) ;Fill contour
  155. skip:
  156.     endfor
  157. free_lun, unit            ;Done
  158. end
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.